#!/bin/bash

# 找到所有 PHP 文件
files=$(find . -name "*.php" -not -path "./vendor/*")

# 初始化错误计数器
error_count=0

for file in $files; do
    # 检查语法
    php -l "$file" > /dev/null
    if [ $? != 0 ]; then
        echo "Syntax error in file: $file"
        error_count=$((error_count + 1))
    fi
done

if [ $error_count -ne 0 ]; then
    echo "$error_count syntax errors detected."
    exit 1
else
    echo "No syntax errors detected."
fi
